package edu.service;

import edu.mapper.MemberMapper;
import edu.pojo.Member;
import edu.pojo.Sum;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberService {

    @Autowired
    private MemberMapper memberMapper;

    /*
    * 依赖注入
    * */
    public void setMemberMapper(MemberMapper memberMapper) {
        this.memberMapper = memberMapper;
    }

    /*
    * 添加报表
    * */
    public int addMember(Member member) {
        return memberMapper.addMember(member);
    }

    /*
    * 根据手机号查询是否已经加入
    * */
    public Sum queryMemberByPhone(String phone) {
        return memberMapper.queryMemberByPhone(phone);
    }

    /*
    * 查询第idx页的人
    * */
    public List<Member> queryMember(int idx) {
        return memberMapper.queryMember((idx - 1) * 15);
    }

    /*
     * 根据关键字查询
     * */
    public List<Member> queryMemberByKey(String key) {
        return memberMapper.queryMemberByKey(key + "%");
    }

    /*
    * 根据id查询报表
    * */
    public Member queryMemberByID(int id) {
        return memberMapper.queryMemberByID(id);
    }

    /*
    * 修改录取状态
    * */
    public int updatePass(int id, int pass) {
        return memberMapper.updatePass(id, pass);
    }

    /*
     * 根据手机号查询个人信息
     * */
    public Member queryByPhone(String phone) {
        return memberMapper.queryByPhone(phone);
    }

    /*
    * 根据邮箱判重
    * */
    public Sum queryByEmail(String email) {
        return memberMapper.queryByEmail(email);
    }

    /*
     * 根据邮箱查询信息
     * */
    public Member queryMemberByEmail(String email) {
        return memberMapper.queryMemberByEmail(email);
    }

    /*
     * 查询所有的member
     * */
    public List<Member> queryAllMember() {
        return memberMapper.queryAllMember();
    }

    /*
     * 选出未确定的人员
     * */
    public List<Member> queryAllUnchecked() {
        return memberMapper.queryAllUnchecked();
    }

    /*
     * 查询总人数
     * */
    public Sum queryAll() {
        return memberMapper.queryAll();
    }
}
